s = [3, 3];
PQ = paddedsize(size(moon), s);
P = PQ(1);
Q = PQ(2);
F = fft2(moon, P, Q);
spectrum = log(1 + abs(fftshift(F)));
imshow(spectrum, []);
Sobel = fspecial ('sobel');
FSobel = fftshift(freqz2(Sobel, Q, P));
G = FSobel .* F;
gfreq = real(ifft2(G));
gfreq = gfreq(2:P-2, 2:Q-1);
figure;
imshow(abs(gfreq), []);

gspa = imfilter(moon, Sobel);

figure;
imshow(abs(FSobel), [])

figure;
imshow(abs(gspa), [])

gdiff = abs(uint8(gfreq)) - abs(gspa);
figure;
imshow(gdiff, [])

min(min(gdiff))
max(gdiff(:))

figure;
imshow(im2bw(my_normalize(abs(gfreq)), 0.20));
